package com.tunnel.service;

import com.tunnel.common.config.ServerParsConfig;
import com.tunnel.service.server.HttpServer;
import com.tunnel.service.server.Server;
import com.tunnel.service.server.TunnleServer;

/**
 * Hello world!
 */
public class ServiceMain {
    public static void main(String[] args) throws InterruptedException {
        Server tunnleServer = new TunnleServer();
        Server httpServer = new HttpServer();
        ServerParsConfig serverParsConfig = new ServerParsConfig();
        serverParsConfig.parse();
        Thread tunnleThread = new Thread(()->{
            try {
                tunnleServer.init();
                tunnleServer.start(serverParsConfig.serviceConfig);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        tunnleThread.setDaemon(false);
        tunnleThread.start();
        Thread httpThread = new Thread(()->{
            try {
                httpServer.init();
                httpServer.start(serverParsConfig.serviceConfig);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        httpThread.setDaemon(false);
        httpThread.start();

    }
}
